import { getQuestions } from '@/api/test'

const state = {
  //面试题列表
  questions: [],
}

const mutations = {
  save(state, questions) {
    state.questions = questions
  },
}

const actions = {
  //获取并保存面试题
  async saveQuestions({ commit }, data) {
    const res = await getQuestions(data)
    if (res.code == 200) {
      commit('save', res.data)
    } else {
      Promise.reject(new Error('获取面试题失败'))
    }
  },
}
const getters = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
}
